const ValidatorError = require('../../shared/errors/ValidatorError')
class UserError extends ValidatorError {
  constructor(message, status = 400) {
    super(message)
    this.status = status
  }
}

class UsernameExistError extends UserError {
  constructor() {
    super('用户名已存在')
  }
}

class PhoneExistError extends UserError {
  constructor() {
    super('手机号码已存在')
  }
}

class EmailExistError extends UserError {
  constructor() {
    super('邮箱已存在')
  }
}

class UserNotFoundError extends UserError {
  constructor(id) {
    super(`用户【${id}】不存在`)
  }
}

class UserHasRoleError extends UserError {
  constructor(name) {
    super(`用户【${name}】还有角色，请先移除绑定关系`)
  }
}

module.exports = {
  UserNotFoundError,
  UsernameExistError,
  PhoneExistError,
  EmailExistError,
  UserError,
  UserHasRoleError,
}
